package com.bumptech.glide.util;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Build.VERSION;
import android.os.Looper;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;

public final class Util
{
  private static final char[] HEX_CHAR_ARRAY = "0123456789abcdef".toCharArray();
  private static final char[] SHA_1_CHARS = new char[40];
  private static final char[] SHA_256_CHARS = new char[64];

  public static void assertBackgroundThread()
  {
    if (!isOnBackgroundThread())
      throw new IllegalArgumentException("YOu must call this method on a background thread");
  }

  public static void assertMainThread()
  {
    if (!isOnMainThread())
      throw new IllegalArgumentException("You must call this method on the main thread");
  }

  private static String bytesToHex(byte[] paramArrayOfByte, char[] paramArrayOfChar)
  {
    for (int i = 0; i < paramArrayOfByte.length; i++)
    {
      int j = 0xFF & paramArrayOfByte[i];
      paramArrayOfChar[(i * 2)] = HEX_CHAR_ARRAY[(j >>> 4)];
      paramArrayOfChar[(1 + i * 2)] = HEX_CHAR_ARRAY[(j & 0xF)];
    }
    return new String(paramArrayOfChar);
  }

  public static <T> Queue<T> createQueue(int paramInt)
  {
    return new ArrayDeque(paramInt);
  }

  public static int getBitmapByteSize(int paramInt1, int paramInt2, Bitmap.Config paramConfig)
  {
    return paramInt1 * paramInt2 * getBytesPerPixel(paramConfig);
  }

  @TargetApi(19)
  public static int getBitmapByteSize(Bitmap paramBitmap)
  {
    if (Build.VERSION.SDK_INT >= 19)
      try
      {
        int i = paramBitmap.getAllocationByteCount();
        return i;
      }
      catch (NullPointerException localNullPointerException)
      {
      }
    return paramBitmap.getHeight() * paramBitmap.getRowBytes();
  }

  private static int getBytesPerPixel(Bitmap.Config paramConfig)
  {
    if (paramConfig == null)
      paramConfig = Bitmap.Config.ARGB_8888;
    switch (1.$SwitchMap$android$graphics$Bitmap$Config[paramConfig.ordinal()])
    {
    default:
      return 4;
    case 1:
      return 1;
    case 2:
    case 3:
    }
    return 2;
  }

  @Deprecated
  public static int getSize(Bitmap paramBitmap)
  {
    return getBitmapByteSize(paramBitmap);
  }

  public static <T> List<T> getSnapshot(Collection<T> paramCollection)
  {
    ArrayList localArrayList = new ArrayList(paramCollection.size());
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext())
      localArrayList.add(localIterator.next());
    return localArrayList;
  }

  public static boolean isOnBackgroundThread()
  {
    return !isOnMainThread();
  }

  public static boolean isOnMainThread()
  {
    return Looper.myLooper() == Looper.getMainLooper();
  }

  private static boolean isValidDimension(int paramInt)
  {
    return (paramInt > 0) || (paramInt == -2147483648);
  }

  public static boolean isValidDimensions(int paramInt1, int paramInt2)
  {
    return (isValidDimension(paramInt1)) && (isValidDimension(paramInt2));
  }

  public static String sha1BytesToHex(byte[] paramArrayOfByte)
  {
    synchronized (SHA_1_CHARS)
    {
      String str = bytesToHex(paramArrayOfByte, SHA_1_CHARS);
      return str;
    }
  }

  public static String sha256BytesToHex(byte[] paramArrayOfByte)
  {
    synchronized (SHA_256_CHARS)
    {
      String str = bytesToHex(paramArrayOfByte, SHA_256_CHARS);
      return str;
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.bumptech.glide.util.Util
 * JD-Core Version:    0.6.2
 */